package com.esunny.fptree;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;

/**
 * 类DataRetrieveServiceFileImpl.java的实现描述：TODO 类实现描述 
 * @author jenvin 2012-7-27 下午12:58:36
 */
public class DataRetrieveServiceFileImpl implements DataRetrieveService {

    @Override
    public List<List<String>> getRecords() {
        InputStreamReader fr = new InputStreamReader(FreqPrefixTrees.class.getResourceAsStream("data.txt"));
        BufferedReader br = new BufferedReader(fr);
        String line = null;
        List<List<String>> records = new LinkedList<List<String>>();
        List<String> record;
        try {
            while ((line = br.readLine()) != null) {
                if (line.trim() != "") {
                    record = new LinkedList<String>();
                    String[] items = line.split("[，|,]");
                    for (String item : items) {
                        record.add(item);
                    }
                    records.add(record);
                }
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return records;
    }

}
